package com.rapid.maintenance.ui.fragment;

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.rapid.maintenance.R;
import com.rapid.maintenance.adapter.LatestBusinessNeedsAdapter;
import com.rapid.maintenance.adapter.RecommendedMallAdapter;
import com.rapid.maintenance.adapter.RecommendedProductsAdapter;
import com.rapid.maintenance.base.BaseFragment;
import com.rapid.maintenance.ui.activity.auctionhouse.PurchasingHallActivity;
import com.rapid.maintenance.ui.activity.machining.MachiningMainActivity;
import com.rapid.maintenance.ui.activity.paimai.PaimaiProtocoActivity;
import com.rapid.maintenance.ui.activity.productmall.ProductMallMainActivity;
import com.rapid.maintenance.ui.activity.quickpurchase.QuickPurchaseMainActivity;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;


public class HomePageFragment extends BaseFragment {
    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";
    @BindView(R.id.tv_auction_mall)
    TextView paimain;
    @BindView(R.id.tv_location)
    TextView tvLocation;
    @BindView(R.id.tv_message)
    TextView tvMessage;
    @BindView(R.id.tv_sign_in)
    TextView tvSignIn;
    @BindView(R.id.rl_tool_bar)
    RelativeLayout rlToolBar;
    @BindView(R.id.ll_search_bar)
    LinearLayout llSearchBar;
    @BindView(R.id.tv_immediate_repair)
    TextView tvImmediateRepair;
    @BindView(R.id.tv_quick_purchase)
    TextView tvQuickPurchase;
    @BindView(R.id.tv_supply_demand_hall)
    TextView tvSupplyDemandHall;
    @BindView(R.id.tv_machine_order)
    TextView tvMachineOrder;
    @BindView(R.id.tv_bargain_mart)
    TextView tvBargainMart;
    @BindView(R.id.tv_haste_college)
    TextView tvHasteCollege;
    @BindView(R.id.tv_more)
    TextView tvMore;
    @BindView(R.id.rv_recommended_mall)
    RecyclerView rvRecommendedMall;
    @BindView(R.id.rv_latest_business_needs)
    RecyclerView rvLatestBusinessNeeds;
    @BindView(R.id.rv_recommended_products)
    RecyclerView rvRecommendedProducts;

    private RecommendedMallAdapter recommendedMallAdapter;
    private LatestBusinessNeedsAdapter latestBusinessNeedsAdapter;
    private RecommendedProductsAdapter recommendedProductsAdapter;
    private String mParam1;
    private String mParam2;

    public HomePageFragment() {
    }

    public static HomePageFragment newInstance(String param1, String param2) {
        HomePageFragment fragment = new HomePageFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected void init() {
        rvRecommendedMall.setLayoutManager(new LinearLayoutManager(requireContext(), RecyclerView.HORIZONTAL, false));
        rvRecommendedMall.setAdapter(recommendedMallAdapter = new RecommendedMallAdapter());
        rvLatestBusinessNeeds.setLayoutManager(new LinearLayoutManager(requireContext()));
        rvLatestBusinessNeeds.setAdapter(latestBusinessNeedsAdapter = new LatestBusinessNeedsAdapter());
        rvRecommendedProducts.setLayoutManager(new LinearLayoutManager(requireContext()));
        rvRecommendedProducts.setAdapter(recommendedProductsAdapter = new RecommendedProductsAdapter());
        List<Object> data = new ArrayList<>();
        data.add(new Object());
        data.add(new Object());
        data.add(new Object());
        recommendedProductsAdapter.setNewData(data);
        recommendedMallAdapter.setNewData(data);
        latestBusinessNeedsAdapter.setNewData(data);

        rvRecommendedMall.setNestedScrollingEnabled(false);
        rvLatestBusinessNeeds.setNestedScrollingEnabled(false);
        rvRecommendedProducts.setNestedScrollingEnabled(false);
    }


    @Override
    protected int provideRootLayout() {
        return R.layout.fragment_page_home;
    }

    @OnClick({R.id.tv_location, R.id.tv_message, R.id.tv_sign_in, R.id.tv_immediate_repair, R.id.tv_quick_purchase, R.id.tv_supply_demand_hall, R.id.tv_machine_order, R.id.tv_bargain_mart, R.id.tv_auction_mall, R.id.tv_haste_college, R.id.tv_more})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_location:
                break;
            case R.id.tv_message:
                break;
            case R.id.tv_sign_in:
                break;
            case R.id.tv_immediate_repair:
                break;
            case R.id.tv_quick_purchase:
                startActivity(QuickPurchaseMainActivity.class);
                break;
            case R.id.tv_supply_demand_hall:
                startActivity(PurchasingHallActivity.class);
                break;
            case R.id.tv_machine_order:
                startActivity(MachiningMainActivity.class);
                break;
            case R.id.tv_bargain_mart:
                startActivity(ProductMallMainActivity.class);
                break;
            case R.id.tv_auction_mall:
                startActivity(PaimaiProtocoActivity.class);
                break;
            case R.id.tv_haste_college:
                break;
            case R.id.tv_more:
                break;
        }
    }
}
